<template>
    <div id="SearchMenu">
      <div class="wrap">
      <div class="content" >
        <div class="title-head"><h1 class="receipt">“{{$store.state.searchMsg}}”的相关菜单</h1></div>
      <div class="mt25"><ul class="cooklist">
        <li class="cookdetail" v-for="menu in menulist" :key="menu.menuId">
          <router-link :to="{name: 'MenuListDetails',params: {id: menu.menuFatherId}}">
              <img :src="menu.menuFatherSrc" alt="" class="cook-img">
          </router-link>
      <div class="cook-info">
        <router-link :to="{name: 'MenuListDetails',params: {id: menu.menuFatherId}}">
          <div class="cook-nickname">{{menu.menuFatherName}}</div>
          </router-link>
        <!-- <p class="major">{{menu.menuFatherIntroduce}}</p> -->
       <div class="score"><span>收藏：</span><b>{{menu.collection}}</b>
       </div>
       <div class="auther">
           <router-link :to="{name: 'CenterRecipes',params: {  userId:menu.userId}}">
           <img :src="menu.headImg" alt="" class="auther-head">{{menu.nickname}}
          </router-link>
           </div></div>
     </li>
     </ul></div>
      </div>
    </div>
<span v-show="displaycontent" class="nocontent">暂时没有更多的内容~</span>
<div v-show="buttonpage">
     <el-pagination  background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNow"
      :page-sizes="[1, 2, 5, 10]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination></div></div>
</template>
<script>
// import LoginVue from '../../Login.vue'
// import cookie from '../../../cookien/index'

export default {
  name: 'SearchMenu',
  data () {
    return {
      total: 0,
      menulist: [],
      pageNow: 1,
      pageSize: 5,
      displaycontent: false,
      buttonpage: false
    }
  },
  created () {
    this.SearchMenu()
  },
  methods: {
    // 搜索菜单
    SearchMenu () {
      console.log(111)
      console.log(this.searchwords)
      this.$axios({
        method: 'get',
        url: '/Menu/Visitor/findMenuFatherByNameLike',
        params: {
          pageNow: this.pageNow,
          pageSize: this.pageSize,
          key: this.$store.state.searchMsg
        },
        headers: {
          token: this.$store.state.token
        }
      }).then(data => {
        console.log(data)
        console.log(data.data.object.list.length === 0)
        if (data.data.object.list.length === 0) {
          this.displaycontent = true
          this.buttonpage = false
        } else {
          this.displaycontent = false
          this.buttonpage = true
          this.menulist = data.data.object.list
          this.total = data.data.object.total
        }
      })
    },
    // 监测当前一页有几条数据
    handleSizeChange (size) {
      this.pageSize = size
      this.SearchMenu()
    },
    // 监测当前页数
    handleCurrentChange (num) {
      this.pageNow = num
      this.SearchMenu()
    }
  }
}
</script>
<style lang="less" scoped>
.nocontent{
    margin: 40px;
    display: block;
    text-align: center;
    color: #999;
}
a{
  text-decoration: none;
  padding: 0 10px;
    font-size: 14px;
    color: #333;
}
.content{
  width: 1000px;
  margin: 0 auto;
  .title-head{
    line-height: 18px;
    margin-top: 20px;
    .receipt{
      font-size: 18px;
      font-weight: bold
    }
  }
  .sort-more{
    margin: 25px 0;
  }
  .mt25{
    margin-top: 25px;
    .cooklist{
      list-style: none;
      display: flex;
    flex-wrap: wrap;
    min-height: 300px;
    width: 1000px;
      .cookdetail{
        padding-bottom: 40px;
        width: 306px;
    height: 210px;
    border-radius: 8px;
    float: left;
    position: relative;
    margin-right: 20px;
    margin-bottom: 41px;
    overflow: hidden;
        .cook-img{
          width: 180px;
          height: 125px;
          float: left;
          border-radius: 8px;
          overflow: hidden;
          margin-right: 15px;
        }
        .cook-info{width: 495px;
    height: 125px;
    float: left;
    // background-color: aquamarine;
       .cook-nickname{
         padding-top: 8px;
        font-size: 18px;
        font-weight: bold;
        overflow: hidden;
        line-height: 18px;
        display: inline-block;
        width: 483px;
        margin-bottom: 5px;
        &:hover{
          color: #FFB31A
        }
       }
       .major{
         text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        font-size: 14px;
        color: #2a2a2a;
        line-height: 14px;
        text-indent: 12px;
       }
       .score{
         width: 91px;
         height: 16px;
         margin: 0 12px 10px;
         span{
           text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          font-size: 14px;
          color: #2a2a2a;
          line-height: 14px;
          vertical-align: middle;
         }
         .auther{
           font-size: 14px;
          line-height: 22px;
          height: 24px;
         }
       }
    }
      }
    }
    }
}
.auther-head{
  display: inline-block;
  width: 21px;
  height: 21px;
  vertical-align: middle;
  border-radius: 50%;
    position: relative;
    top: -2px;
    padding-right: 10px;
}
.el-pagination{
text-align: center
}
</style>
